﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace HotellApplikationASP
{
    public class MailClient
    {
         private SmtpClient _client;

        public void MyMail(string to, string subject, string body)
        {

            var thread = new Thread(delegate()
            {
            _client = new SmtpClient
            {
                Host = "mail.nackademin.se",
                Credentials = new NetworkCredential("Syh14s573", "Important44")
            }; 

            var message = new MailMessage();
            message.From = new MailAddress("jonas.ciechomski@yh.nackademin.se");
            message.To.Add(new MailAddress(to)); //flera möjliga
            message.Subject = subject;
            message.Body = body;

            //message.Attachments.Add(new Attachment("myfile"));
            _client.Send(message);
            message.Dispose();
            _client.Dispose();

             });
            thread.Start();
            thread.Join();
            
        }
    }

}
